package org.example.DesignPatterns.Proxy;

/**
 * @description:
 * @author: farprt
 * @create: 2022-08-14 01:55
 **/
public class SimpleStaticProxyDemo {
    interface IService{
        public void sayHello();
    }

    static class RealService implements IService{
        @Override
        public void sayHello() {
            System.out.println("hello");
        }
    }

    static class TraceProxy implements IService{
        private IService realService;
        public TraceProxy(IService realService){
            this.realService=realService;
        }

        @Override
        public void sayHello() {
            System.out.println("entering sayHello");
            this.realService.sayHello();
            System.out.println("leaving sayHello");
        }
    }

    public static void main(String[] args) {
        IService realService = new RealService();
        IService proxyService=new TraceProxy(realService);
        proxyService.sayHello();
    }
}